package com.sgzn.sgpay.util;

import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by Chenkh on 2015/3/11.
 */
@Slf4j
public class IpUtils {

    private static String localhostIp = null;

    public static String getLocalhostIp() {
        if (localhostIp == null) {
            try {
                localhostIp = InetAddress.getLocalHost().getHostAddress();
            } catch (UnknownHostException e) {
                log.warn("无法获取本机IP，详细信息：[{}]", e);
            }
        }
        return localhostIp;
    }
}
